<?php

class Materials_Model_Material_Observer_LabelRankUpdater extends Workset_Model_Observer_Abstract {
    
    function afterLinkObject(Workset_Model_Subject_Interface $object, $data = null) {
        if ($data instanceof Materials_Model_Label) {

            $label = $data;

            $label['rank'] = $label->materialsCount();
            $label->save();
        }
    }

    function afterUnlinkObject(Workset_Model_Subject_Interface $object, $data = null) {
        if ($data instanceof Materials_Model_Label) {
            $label = $data;

            $label['rank'] = $label->materialsCount();
            $label->save();
        }
    }

}